/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DailyReportByUserPnl.java
 *
 * Created on Jul 17, 2011, 10:56:32 PM
 */
package com.viweb.storemanager.report;

import com.jidesoft.swing.JideTabbedPane;
import com.viweb.storemanager.core.ColumnData;
import com.viweb.storemanager.core.DefaultObjectTableModel;
import com.viweb.storemanager.core.MyListCellRenderer;
import com.viweb.storemanager.core.ObjectComboBoxModel;
import java.util.Date;
import java.util.List;
import javax.swing.JTable;
import javax.swing.JViewport;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingConstants;

/**
 *
 * @author qhvic
 */
public class DailyReportByUserPnl extends javax.swing.JPanel {

    private JTable headerTablePayment;
    private JTable headerTableDrink;
    private List users;
    private List drinks;

    /** Creates new form DailyReportByUserPnl */
    public DailyReportByUserPnl() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        dateReportDate = new com.toedter.calendar.JDateChooser();
        pnlMainFunction = new javax.swing.JPanel();
        tbpDailyReport = new JideTabbedPane();
        pnlPayments = new javax.swing.JPanel();
        scpPayment = new javax.swing.JScrollPane();
        tblPayment = new javax.swing.JTable();
        pnlDrinks = new javax.swing.JPanel();
        scpDrink = new javax.swing.JScrollPane();
        tblDrink = new javax.swing.JTable();
        lblDate = new javax.swing.JLabel();
        pnlSumary = new javax.swing.JPanel();
        lblTotal = new javax.swing.JLabel();
        btnPrint = new javax.swing.JButton();
        lblUsers = new javax.swing.JLabel();
        cmbUsers = new javax.swing.JComboBox();
        pnlTime = new javax.swing.JPanel();
        lblTime = new javax.swing.JLabel();
        spnHourStart = new javax.swing.JSpinner();
        spnMinuteStart = new javax.swing.JSpinner();
        lblFinish = new javax.swing.JLabel();
        spnHourFinish = new javax.swing.JSpinner();
        spnMinuteFinish = new javax.swing.JSpinner();
        btnView = new javax.swing.JButton();
        lblHourStart = new javax.swing.JLabel();
        lblMinuteStart = new javax.swing.JLabel();
        lblHourFinish = new javax.swing.JLabel();
        lblMinuteFinish = new javax.swing.JLabel();
        lblDateValue = new javax.swing.JLabel();

        dateReportDate.setDate(new Date());
        dateReportDate.setDateFormatString("dd/MM/yyyy");
        dateReportDate.setEnabled(false);
        dateReportDate.setMinimumSize(new java.awt.Dimension(90, 22));
        dateReportDate.setPreferredSize(new java.awt.Dimension(90, 22));

        setLayout(new java.awt.BorderLayout());

        pnlMainFunction.setLayout(new java.awt.GridBagLayout());

        tbpDailyReport.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Nội dung báo cáo", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), java.awt.Color.blue));
        ((JideTabbedPane) tbpDailyReport).setTabShape(JideTabbedPane.SHAPE_DEFAULT);
        ((JideTabbedPane) tbpDailyReport).setBoldActiveTab(true);

        pnlPayments.setLayout(new java.awt.GridBagLayout());

        tblPayment.setRowHeight(22);
        ColumnData[] columnsPayment = {new ColumnData("Số", 70, SwingConstants.LEFT, 1),
            new ColumnData("Bàn", 70, SwingConstants.LEFT, 2),
            new ColumnData("Vào", 50, SwingConstants.CENTER, 4),
            new ColumnData("Ra", 50, SwingConstants.CENTER, 5),
            new ColumnData("Giảm", 50, SwingConstants.CENTER, 6),
            new ColumnData("Thanh toán", 80, SwingConstants.RIGHT, 3, ColumnData.NUMBER_RENDERER),
            new ColumnData("Ghi chú", 250, SwingConstants.LEFT, 7)

        };
        DefaultObjectTableModel modelPayment = new DefaultObjectTableModel(tblPayment, columnsPayment, null, false);

        headerTablePayment = modelPayment.getHeaderTable();
        headerTablePayment.createDefaultColumnsFromModel();
        tblPayment.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

        // Put it in a viewport that we can control a bit
        JViewport viewportPayment = new JViewport();
        viewportPayment.setView(headerTablePayment);
        viewportPayment.setPreferredSize(headerTablePayment.getMaximumSize());

        scpPayment.setRowHeader(viewportPayment);
        scpPayment.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, headerTablePayment
            .getTableHeader());
        scpPayment.setViewportView(tblPayment);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        pnlPayments.add(scpPayment, gridBagConstraints);

        tbpDailyReport.addTab("Theo hoá đơn", pnlPayments);

        pnlDrinks.setLayout(new java.awt.GridBagLayout());

        tblDrink.setRowHeight(22);
        ColumnData[] columnsDrink = {new ColumnData("Tên thức uống", 150, SwingConstants.LEFT, 1),
            new ColumnData("Số lượng", 100, SwingConstants.CENTER, 7),
            new ColumnData("Đơn giá", 100, SwingConstants.RIGHT, 5, ColumnData.NUMBER_RENDERER),
            new ColumnData("Thành tiền", 150, SwingConstants.RIGHT, 8, ColumnData.NUMBER_RENDERER)
        };
        DefaultObjectTableModel modelDrink = new DefaultObjectTableModel(tblDrink, columnsDrink, null, false);

        headerTableDrink = modelDrink.getHeaderTable();
        headerTableDrink.createDefaultColumnsFromModel();
        tblDrink.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

        // Put it in a viewport that we can control a bit
        JViewport viewportDrink = new JViewport();
        viewportDrink.setView(headerTableDrink);
        viewportDrink.setPreferredSize(headerTableDrink.getMaximumSize());

        scpDrink.setRowHeader(viewportDrink);
        scpDrink.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, headerTableDrink
            .getTableHeader());
        scpDrink.setViewportView(tblDrink);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        pnlDrinks.add(scpDrink, gridBagConstraints);

        tbpDailyReport.addTab("Theo thức uống", pnlDrinks);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5);
        pnlMainFunction.add(tbpDailyReport, gridBagConstraints);

        lblDate.setText("Ngày báo cáo:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0);
        pnlMainFunction.add(lblDate, gridBagConstraints);

        pnlSumary.setLayout(new java.awt.GridBagLayout());

        lblTotal.setFont(new java.awt.Font("Tahoma", 1, 12));
        lblTotal.setText("Tổng cộng:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        pnlSumary.add(lblTotal, gridBagConstraints);

        btnPrint.setText("Xem/In báo cáo");
        btnPrint.setToolTipText("Xem kết quả báo cáo sau khi nhấn vào nút Xem ở trên");
        btnPrint.setEnabled(false);
        btnPrint.setMinimumSize(new java.awt.Dimension(128, 25));
        btnPrint.setPreferredSize(new java.awt.Dimension(128, 25));
        btnPrint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPrintActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
        pnlSumary.add(btnPrint, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        pnlMainFunction.add(pnlSumary, gridBagConstraints);

        lblUsers.setText("Thu ngân:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(5, 10, 0, 0);
        pnlMainFunction.add(lblUsers, gridBagConstraints);

        cmbUsers.setMinimumSize(new java.awt.Dimension(231, 22));
        cmbUsers.setPreferredSize(new java.awt.Dimension(231, 22));
        ObjectComboBoxModel modelUser = new ObjectComboBoxModel(this.users);
        cmbUsers.setModel(modelUser);
        cmbUsers.setRenderer(new MyListCellRenderer(22));
        cmbUsers.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cmbUsersItemStateChanged(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0);
        pnlMainFunction.add(cmbUsers, gridBagConstraints);

        pnlTime.setLayout(new java.awt.GridBagLayout());

        lblTime.setText("Thời gian:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        pnlTime.add(lblTime, gridBagConstraints);

        spnHourStart.setModel(new SpinnerNumberModel(7, 
            1,    //min
            24, //max
            1));
    spnHourStart.setMinimumSize(new java.awt.Dimension(40, 20));
    spnHourStart.setPreferredSize(new java.awt.Dimension(40, 20));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.insets = new java.awt.Insets(0, 28, 0, 0);
    pnlTime.add(spnHourStart, gridBagConstraints);

    spnMinuteStart.setModel(new SpinnerNumberModel(0, 
        0,    //min
        60, //max
        30));
spnMinuteStart.setMinimumSize(new java.awt.Dimension(40, 20));
spnMinuteStart.setPreferredSize(new java.awt.Dimension(40, 20));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
pnlTime.add(spnMinuteStart, gridBagConstraints);

lblFinish.setText("-");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 5;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
pnlTime.add(lblFinish, gridBagConstraints);

spnHourFinish.setModel(new SpinnerNumberModel(11, 
    1,    //min
    24, //max
    1));
    spnHourFinish.setMinimumSize(new java.awt.Dimension(40, 20));
    spnHourFinish.setPreferredSize(new java.awt.Dimension(40, 20));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 6;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.insets = new java.awt.Insets(0, 11, 0, 0);
    pnlTime.add(spnHourFinish, gridBagConstraints);

    spnMinuteFinish.setModel(new SpinnerNumberModel(30, 
        0,    //min
        60, //max
        30));
spnMinuteFinish.setMinimumSize(new java.awt.Dimension(40, 20));
spnMinuteFinish.setPreferredSize(new java.awt.Dimension(40, 20));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 8;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
pnlTime.add(spnMinuteFinish, gridBagConstraints);

btnView.setText("Xem");
btnView.setMinimumSize(new java.awt.Dimension(80, 25));
btnView.setPreferredSize(new java.awt.Dimension(80, 25));
btnView.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnViewActionPerformed(evt);
    }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 10;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(0, 18, 0, 0);
    pnlTime.add(btnView, gridBagConstraints);

    lblHourStart.setText("giờ");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 0);
    pnlTime.add(lblHourStart, gridBagConstraints);

    lblMinuteStart.setText("phút");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 4;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 0);
    pnlTime.add(lblMinuteStart, gridBagConstraints);

    lblHourFinish.setText("giờ");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 7;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 0);
    pnlTime.add(lblHourFinish, gridBagConstraints);

    lblMinuteFinish.setText("phút");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 9;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 0);
    pnlTime.add(lblMinuteFinish, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridwidth = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5);
    pnlMainFunction.add(pnlTime, gridBagConstraints);

    lblDateValue.setMinimumSize(new java.awt.Dimension(90, 20));
    lblDateValue.setPreferredSize(new java.awt.Dimension(90, 20));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0);
    pnlMainFunction.add(lblDateValue, gridBagConstraints);

    add(pnlMainFunction, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents

    private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrintActionPerformed
}//GEN-LAST:event_btnPrintActionPerformed

    private void cmbUsersItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmbUsersItemStateChanged
}//GEN-LAST:event_cmbUsersItemStateChanged

    private void btnViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewActionPerformed
}//GEN-LAST:event_btnViewActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnPrint;
    private javax.swing.JButton btnView;
    private javax.swing.JComboBox cmbUsers;
    private com.toedter.calendar.JDateChooser dateReportDate;
    private javax.swing.JLabel lblDate;
    private javax.swing.JLabel lblDateValue;
    private javax.swing.JLabel lblFinish;
    private javax.swing.JLabel lblHourFinish;
    private javax.swing.JLabel lblHourStart;
    private javax.swing.JLabel lblMinuteFinish;
    private javax.swing.JLabel lblMinuteStart;
    private javax.swing.JLabel lblTime;
    private javax.swing.JLabel lblTotal;
    private javax.swing.JLabel lblUsers;
    private javax.swing.JPanel pnlDrinks;
    private javax.swing.JPanel pnlMainFunction;
    private javax.swing.JPanel pnlPayments;
    private javax.swing.JPanel pnlSumary;
    private javax.swing.JPanel pnlTime;
    private javax.swing.JScrollPane scpDrink;
    private javax.swing.JScrollPane scpPayment;
    private javax.swing.JSpinner spnHourFinish;
    private javax.swing.JSpinner spnHourStart;
    private javax.swing.JSpinner spnMinuteFinish;
    private javax.swing.JSpinner spnMinuteStart;
    private javax.swing.JTable tblDrink;
    private javax.swing.JTable tblPayment;
    private javax.swing.JTabbedPane tbpDailyReport;
    // End of variables declaration//GEN-END:variables
}
